package com.lee.springbootshiro.service.impl;

import com.lee.springbootshiro.po.AccountProfile;
import com.lee.springbootshiro.service.UserService;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.stereotype.Service;

/**
 * @author jackielee
 * @version 1.0
 * @description UserServiceImpl
 * @date 2021/4/9
 **/
@Service
public class UserServiceImpl implements UserService {
    @Override
    public AccountProfile login(String username, String password) {
        if(!"lee".equals(username)){
            throw new UnknownAccountException("用户名不存在"); // 抛出shiro异常，方便通知用户错误信息
        }
        if(!"123456".equals(password)){
            throw new IncorrectCredentialsException("密码错误");
        }

        AccountProfile profile = new AccountProfile();
        profile.setId(1L);
        profile.setUserName("lee");
        profile.setSign("欢迎您");

        return profile;
    }
}
